package refactor.changeunidirectionalassociationtobidirectional.result;

public class Order {
    private String id;
    private Customer customer;

    public Order(String id) {
        this.id = id;
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        if (this.customer != null) {
            this.customer.getOrders().remove(this);
        }
        this.customer = customer;
        if (this.customer != null) {
            this.customer.getOrders().add(this);
        }
    }

    public String getId() {
        return id;
    }

    public String state() {
        return "order id:" + id + ",customer name:" + customer.getName();
    }
}
